import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AppVO, AppForm, AppQuery } from '@/api/system/app/types';

/**
 * 查询应用列表
 * @param query
 * @returns {*}
 */

export const listApp = (query?: AppQuery): AxiosPromise<AppVO[]> => {
  return request({
    url: '/system/app/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询应用详细
 * @param appId
 */
export const getApp = (appId: string | number): AxiosPromise<AppVO> => {
  return request({
    url: '/system/app/' + appId,
    method: 'get'
  });
};

/**
 * 新增应用
 * @param data
 */
export const addApp = (data: AppForm) => {
  return request({
    url: '/system/app',
    method: 'post',
    data: data
  });
};

/**
 * 修改应用
 * @param data
 */
export const updateApp = (data: AppForm) => {
  return request({
    url: '/system/app',
    method: 'put',
    data: data
  });
};

/**
 * 删除应用
 * @param appId
 */
export const delApp = (appId: string | number | Array<string | number>) => {
  return request({
    url: '/system/app/' + appId,
    method: 'delete'
  });
};
